$(function(){
	var url='../exam/questionbankMultiSelectInfo?qbId='+$("#qbid").val();
	$('#questionbankMultiSelect').datagrid({
	    url:url,
	    columns:[[
	    	{field:'multiselectId',title:"编号",width:50,align:'center'},
			{field:'examQuestion',title:"考题",width:200,align:'center'},
			{field:'answer',title:"答案",width:50,align:'center'},
			{field:'a',title:"A",width:80,align:'center'},
			{field:'b',title:"B",width:80,align:'center'},
			{field:'c',title:"C",width:80,align:'center'},
			{field:'d',width:80,title:"D",align:'center'},
			{field:'createPeople',title:"创建人",width:80,align:'center'},
			{field:'createDate',title:"创建时间",width:150,align:'center'},
			{field:'',width:100,align:'center',checkbox:true}
	    ]],
		fit:true,
		method:'get',
		toolbar:'#questionbankmultiselect_tb',
		rownumbers:true,
		width: 700,
		height: 250,
		//显示分页栏
		pagination:true,
		//设置每页大小
		pageSize:5,
		//可选的每页大小
		pageList:[5,10,20,50],
	});
	$("#addQuestionbankMultiSelect").on('click',function(){
		$("#wjladdquestionbankMultiSelect").window("open");
	});
	$("#questionbankMultiSelectDelete").bind('click',function(){
		var rows = $('#questionbankMultiSelect').datagrid('getSelections');
		var multiSelectIds=[];
		for(var i=0;i<rows.length;i++){
			multiSelectIds.push(rows[i].multiselectId);
		}
		var wjl_rowdata=JSON.stringify(multiSelectIds);
		alert(wjl_rowdata);
		$.ajax({
			url:"../exam/deleteQuestionBankMultiSelect",
			data:{"wjl_rowdata":wjl_rowdata},
			success : function(e) {
				if (e.success) {
					$('#questionbankMultiSelect').datagrid('load');
                   alert("删除成功");
                   
				}
			}
			
		});
	});
	$('#wjladdquestionbankMultiSelect').dialog({
		buttons : [ {
			text : '保存',
			iconCls : 'icon-save',
			handler : function() {
				$('#ff0').form('submit', {
					onSubmit : function(param) {
						var examQuestion=$("#examQuestion1").val();
						var A=$("#A1").val();
						var B=$("#B1").val();
						var C=$("#C1").val();
						var D=$("#D1").val();
						var answer=$("#answer1").val();
						var qbId=""+$("#qbid").val();
						var multiselects=[];
						var multiselect={
								examQuestion:examQuestion,
								A:A,
								B:B,
								C:C,
								D:D,
								answer:answer,
								qbId:qbId
						}
						multiselects.push(multiselect);
						var jsondata = JSON.stringify(multiselects);
						$.ajax({
							url:"../exam/addquestionbanMultiSelect",
							data : {"jsondata" : jsondata},
							success : function(data) {
								if (data.success) {
	                               alert("存储成功");
	                               $('#questionbankMultiSelect').datagrid("load");
								}else{
									alert("存储失败")
								}
							}
						});

						$("#wjladdquestionbankMultiSelect").window("close");
						$('#questionbankMultiSelect').datagrid("reload");
					},
					success : function(data) {
						alert(data)
					}
				});

			}
		}, {
			text : '清空',
			iconCls : 'icon-clear',
			handler : function() {
				$('#ff0').form('clear');
			}
		}, {
			text : '取消',
			iconCls : 'icon-cancel',
			handler : function() {
				$("#wjladdquestionbankMultiSelect").window("close");
			}
		} ]
	});
$("#addQuestionbankmultiSelect_search").bind('click',function(){
		
		var select=$("#addQuestionbankMultiSelect_select").val();
		if(select=="单选"){
			update_wjl("../exam/questionbankSingleChoice");
		}else if(select=="判断"){
			update_wjl("../exam/questionbankJudge");
		}else if(select=="填空"){
			update_wjl("../exam/questionbankFilling");
		}else if(select=="综合"){
			update_wjl("../exam/questionbankComprehensive");
		}
		
		
	});
	/*$.ajax({
		url:url,
		datatype:'json',
		success:function(result){
			var result=JSON.stringify(result);
			
		}
	})*/
})